/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.reporte.convertidores;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;
import org.reporte.control.Conexion;
import org.reporte.modelo.ParametroReporte;

/**
 *
 * @author 43579648
 */
@FacesConverter(forClass=ParametroReporte.class)
public class ParametroReporteConvertidor implements Converter{



    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        return Conexion.getEntityManager().createNamedQuery("ParametroReporte.findByIdParametroReporte").setParameter("idParametroReporte", Integer.parseInt(value)).getSingleResult();
    }

    public String getAsString(FacesContext context, UIComponent component, Object value) {
        return ((ParametroReporte) value).getIdParametroReporte().toString();
    }

}
